package br.com.recipe.dao;

import java.util.List;
import java.util.Map;

import br.com.recipe.entity.Usuario;
import br.com.recipe.exception.RecipeException;

public class UsuarioDAO implements DAO {
	private static UsuarioDAO instance;	
	
	private UsuarioDAO() {}
	
	public static UsuarioDAO getInstance() {
		if (instance == null) {
			instance = new UsuarioDAO();
		}
		return instance;
	}

	@Override
	public void save(Object o) throws RecipeException {
		HibernateHelper.save(o);

	}

	@Override
	public void delete(Object o) throws RecipeException {
		HibernateHelper.delete(o);
	}

	@Override
	public Usuario getById(Class<?> c, Integer id) throws RecipeException {
		return (Usuario) HibernateHelper.getById(Usuario.class, id);
	}

	@SuppressWarnings("unchecked")
	@Override
	public List<Usuario> execQuery(String hql) throws RecipeException {
		return (List<Usuario>) HibernateHelper.execQuery(hql);
	}

	@SuppressWarnings("unchecked")
	@Override
	public List<Usuario> execQuery(String hql, Map<?, ?> params) throws RecipeException {
		return (List<Usuario>) HibernateHelper.execQuery(hql, params);
	}

}
